package cn.itcast.web.servlet;

import cn.itcast.daomain.comment;
import cn.itcast.daomain.commodity;
import cn.itcast.service.UserService;
import cn.itcast.service.impl.UserServiceImpl;

import javax.servlet.*;
import javax.servlet.annotation.*;
import javax.servlet.http.*;
import java.io.IOException;
import java.util.List;

@WebServlet("/detailsListServlet")
public class detailsListServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String id= request.getParameter("id");
        String comment_id=request.getParameter("comment_id");
        HttpSession session=request.getSession();

        UserService service=new UserServiceImpl();
        commodity bb=service.detail(id);
        List<comment> pingl=service.comment(comment_id);
        session.setAttribute("pingl",pingl);
        request.setAttribute("details",bb);
        request.getRequestDispatcher("/details.jsp").forward(request,response);


    }
}
